// store/modules/user.ts
import { defineStore ,type StoreDefinition} from 'pinia';
export enum THEMEENUM{ light,dark }
export interface AppConfigInterface{
    theme: THEMEENUM.light,
    lang : string,
    chatBlock : boolean,
}
export interface AppConfigActionsType{
    changeLang: (value:string)=> void,
    changeChatBlock: (value:boolean)=> void,
}
export interface AppConfigGettersType{
  getTheme: THEMEENUM.light,
  getLang: string,
  getChatBlock: boolean,
}
// @ts-ignore
export const useAppConfigStore: StoreDefinition<"appConfig", AppConfigInterface, AppConfigGettersType, AppConfigActionsType> = defineStore('appConfig', {
  state: () :AppConfigInterface => ({
    theme: THEMEENUM.light,
    lang : 'en',
    chatBlock: false,
  }),
  getters: {
    getTheme: (state:AppConfigInterface) => state.theme,
    getLang: (state:AppConfigInterface) => state.lang,
    getChatBlock: (state:AppConfigInterface) => state.chatBlock,
  },
  actions: {
    changeChatBlock(isBoolean:boolean){
        this.chatBlock = isBoolean;
    },
    changeLang(language:string){
        this.lang = language;
    }
  },
  persist: {
    enabled: true , // 这个配置代表存储生效，而且是整个store都存储
  }
});
